package com.dayuanit.dy14.atm.demo2.dy14atmcommon.util;

import java.math.BigDecimal;

public class MoneyUtil {

    public static String plus(String balacne, String amount) {
        BigDecimal balacneBig = new BigDecimal(balacne);
        BigDecimal amountBig = new BigDecimal(String.valueOf(amount));
        return balacneBig.add(amountBig).setScale(2).toString();
    }

    public static String mul(String price, int number) {
        BigDecimal priceDecimal = new BigDecimal(price);
        BigDecimal numberDecimal = new BigDecimal(String.valueOf(number));

        BigDecimal result = priceDecimal.multiply(numberDecimal).setScale(2, BigDecimal.ROUND_HALF_UP);
        return result.toString();
    }

    public static void main(String[] args) {
        System.out.println(MoneyUtil.mul("0.1", 3));
    }
}
